﻿@using System.Web.Optimization
@using VocaDb.Web.Helpers
@using SharedRes = ViewRes.SharedStrings
@inherits VocaDb.Web.Code.VocaDbPage<VocaDb.Web.Models.User.AlbumCollection>

@{
    PageProperties.Title = "Album collection for " + Model.User.Name;
	ViewBag.Parents = new[] {
		Html.ActionLink(Model.User.Name, "Details", "User", new {id = Model.User.Id}, null)
	};	
}

@{ Html.RenderPartial("Partials/_AlbumCollection"); }

@section BodyScripts {
@Scripts.Render("~/bundles/User/AlbumCollection")

<script type="text/javascript">

	$(document).ready(function () {

		var cultureCode = '@UICulture';
		var languageSelection = '@UserContext.LanguagePreference';
		var loggedUserId = @Model.User.Id;
		var publicCollection = @ToJS(Model.User.PublicAlbumCollection || Model.User.Id == Login.Manager.LoggedUserId);

		var rootPath = '@RootPath';
		var urlMapper = new vdb.UrlMapper(rootPath);
		var repoFactory = new vdb.repositories.RepositoryFactory(urlMapper, @LanguagePreferenceInt);
		var userRepo = repoFactory.userRepository();
		var artistRepo = repoFactory.artistRepository();
		var resourceRepo = repoFactory.resourceRepository();

		var vm = new vdb.viewModels.user.AlbumCollectionViewModel(userRepo, artistRepo, resourceRepo, languageSelection, loggedUserId, cultureCode,
			publicCollection);
		ko.applyBindings(vm);

	});

</script>

}